package com.wjjun.library.widget

import android.content.Context
import android.util.AttributeSet
import android.widget.RadioGroup
import androidx.appcompat.widget.AppCompatRadioButton

/**
 * 支持双向绑定的单选按钮
 * author : wangjunjun
 * date   : 2022/7/26
 * desc   :
 */
class DBRadioButton : AppCompatRadioButton {

    var value: Int = 0
        set(value) {
            field = value
            if (parent is DBRadioGroup) {
                isChecked = (parent as DBRadioGroup).isCheckedValue(value)
            }
        }

    constructor(context: Context) : super(context)
    constructor(context: Context, attributeSet: AttributeSet?) : super(context, attributeSet)
    constructor(context: Context, attributeSet: AttributeSet?, defStyleAttr: Int) : super(
        context,
        attributeSet,
        defStyleAttr
    )

}